﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management;
using System.Text;
using WMI.NET.Abstracts;
using WMI.NET.CIM;

namespace WMI.NET.ComputerSystemHardware.MotherboardControllerPort
{
    /// <summary>
    /// The Win32_SCSIController WMI class represents a SCSI controller on a computer system running Windows.
    /// </summary>
    public class Win32_SCSIController : CIM_SCSIController
    {

        private string _DeviceMap;
        private string _DriverName;
        private string _HardwareVersion;
        private Nullable<UInt32> _Index;
        private string _Manufacturer;

        /// <summary>
        /// Order in which the devices are listed with this SCSI controller.
        /// </summary>
        public string DeviceMap { get { return _DeviceMap; } }

        /// <summary>
        /// Driver file name of the SCSI controller.
        /// Example: "Adaptec"
        /// </summary>
        public string DriverName { get { return _DriverName; } }

        /// <summary>
        /// Hardware version number of the SCSI controller.
        /// Example: "1.25"
        /// </summary>
        public string HardwareVersion { get { return _HardwareVersion; } }

        /// <summary>
        /// Index number of the SCSI controller in the system registry.
        /// Example: 0
        /// </summary>
        public Nullable<UInt32> Index { get { return _Index; } }

        /// <summary>
        /// Name of the SCSI controller manufacturer.
        /// Example: "Adaptec"
        /// </summary>
        public string Manufacturer { get { return _Manufacturer; } }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public Win32_SCSIController(ManagementBaseObject mbo)
            :base(mbo)
        {
            _DeviceMap = mbo.GetStringValue("DeviceMap");
            _DriverName = mbo.GetStringValue("DriverName");
            _HardwareVersion = mbo.GetStringValue("HardwareVersion");
            _Index = mbo.GetUIntValue("Index");
            _Manufacturer = mbo.GetStringValue("Manufacturer");
        }

    }


    /// <summary>
    /// 
    /// </summary>
    public class GetWin32_SCSIControllers : Win32Collection<Win32_SCSIController>
    {

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ReadOnlyCollection<Win32_SCSIController> GetCollection()
        {
            List<Win32_SCSIController> tempCollection = new List<Win32_SCSIController>();

            foreach (var s in searcher.Get())
            {
                Win32_SCSIController tempListItem = new Win32_SCSIController(s);
                tempCollection.Add(tempListItem);
            }

            return tempCollection.AsReadOnly();
        }

        /// <summary>
        /// 
        /// </summary>
        public GetWin32_SCSIControllers() : base("SELECT * FROM Win32_SCSIController") { }

    }
}
